Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): implement OAuth authentication #13151

Merged
merged 17 commits into from
Mar 5, 2024
Merged

Conversation

Rossil2012
Copy link
Contributor

@Rossil2012 Rossil2012 commented Oct 30, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Refer to #11440.

Support to authenticate with OAuth token acquired from cloud.

The basic workflow can be tested as follows:

# create a new user test with OAuth authentication
psql -h localhost -p 4566 -d dev -U root

# in psql
create user test with oauth (
  jwks_url = 'xxx.com',  // required
  issuer = 'risingwave',  // required
  other_params_should_match = 'xxx',  // optional, will be checked against jwt.claims
);

# password here is actually OAuth token, and would be passed with plaintext
psql -h localhost -p 4566 -d dev -U test

kid and alg are required in the header of JWT, and kid is also required in the JWKs returned by the JWKS server. All params set in user creation (except jwks_url) will be checked in the claims of jwt, any mismatch will deny the login process.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

New sql syntax:

create/alter user test with oauth (
  jwks_url = 'xxx.com',  // required
  issuer = 'risingwave',  // required
  other_params_should_match = 'xxx',  // optional, will be checked against jwt.claims
);

Note that key in the options must be SMALL-CASED.

@Rossil2012 Rossil2012 changed the title feat(user): implement OAuth authentication feat(frontend): implement OAuth authentication Oct 30, 2023
Copy link
Member

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's keep this PR and wait for the progress on the cloud side later.

src/utils/pgwire/src/pg_server.rs Outdated Show resolved Hide resolved
Copy link
Contributor

This PR has been open for 60 days with no activity. Could you please update the status? Feel free to ping a reviewer if you are waiting for review.

Copy link

gitguardian bot commented Feb 20, 2024

⚠️ GitGuardian has uncovered 3 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9425213 Triggered Generic Password 169720c ci/scripts/e2e-source-test.sh View secret
9425213 Triggered Generic Password 169720c ci/scripts/e2e-source-test.sh View secret
9425213 Triggered Generic Password 169720c ci/scripts/regress-test.sh View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@Rossil2012 Rossil2012 marked this pull request as ready for review February 22, 2024 01:02
@Rossil2012 Rossil2012 requested a review from a team as a code owner February 22, 2024 01:02
Copy link
Member

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM.

src/common/src/system_param/mod.rs Outdated Show resolved Hide resolved
src/utils/pgwire/src/pg_server.rs Outdated Show resolved Hide resolved
proto/user.proto Outdated Show resolved Hide resolved
Copy link
Member

@yezizp2012 yezizp2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job! Have you tested it with @xuhui-lu ?

@Rossil2012
Copy link
Contributor Author

Good Job! Have you tested it with @xuhui-lu ?

Not yet. Waiting for @xuhui-lu to provide a test jwks server and jwt.

@yezizp2012
Copy link
Member

Hi @Rossil2012 , I resolved all comments and pushed some commits directly in this PR. Please help to verify if on your local setup. Let's merge it and cherry-pick to release 1.7 if it works.

@Rossil2012
Copy link
Contributor Author

Hi @Rossil2012 , I resolved all comments and pushed some commits directly in this PR. Please help to verify if on your local setup. Let's merge it and cherry-pick to release 1.7 if it works.

Wow, thank you! However, in order to support per-user oauth configuration, @xuhui-lu and I determined to add a new syntax like create user u with oauth (jwks_url = 'xxx', user_id = 'xxx'). This way we can enable a more flexible check on the claims decoded from jwt, and community users can build their own oauth authentication workflow by specifying static config in user creation and dynamically check them in jwt header. I will release the details in the introduction later. The system params will not be used then🤣.

@Rossil2012 Rossil2012 added need-cherry-pick-release-1.7 user-facing-changes Contains changes that are visible to users labels Feb 29, 2024
proto/user.proto Outdated Show resolved Hide resolved
src/utils/pgwire/src/pg_server.rs Outdated Show resolved Hide resolved
@stdrc
Copy link
Member

stdrc commented Mar 1, 2024

Hi @Rossil2012 , I resolved all comments and pushed some commits directly in this PR. Please help to verify if on your local setup. Let's merge it and cherry-pick to release 1.7 if it works.

Wow, thank you! However, in order to support per-user oauth configuration, @xuhui-lu and I determined to add a new syntax like create user u with oauth (jwks_url = 'xxx', user_id = 'xxx'). This way we can enable a more flexible check on the claims decoded from jwt, and community users can build their own oauth authentication workflow by specifying static config in user creation and dynamically check them in jwt header. I will release the details in the introduction later. The system params will not be used then🤣.

So IIUC the current implementation is not considered as a stable or final one, right? Is that so urgent that this should be released in 1.7? I would suggest to wait for 1.8 which IIRC will be frozen in recent days.

@Rossil2012
Copy link
Contributor Author

Hi @Rossil2012 , I resolved all comments and pushed some commits directly in this PR. Please help to verify if on your local setup. Let's merge it and cherry-pick to release 1.7 if it works.

Wow, thank you! However, in order to support per-user oauth configuration, @xuhui-lu and I determined to add a new syntax like create user u with oauth (jwks_url = 'xxx', user_id = 'xxx'). This way we can enable a more flexible check on the claims decoded from jwt, and community users can build their own oauth authentication workflow by specifying static config in user creation and dynamically check them in jwt header. I will release the details in the introduction later. The system params will not be used then🤣.

So IIUC the current implementation is not considered as a stable or final one, right? Is that so urgent that this should be released in 1.7? I would suggest to wait for 1.8 which IIRC will be frozen in recent days.

This feature may be urgent for cloud, cc @xuhui-lu.

@xuhui-lu
Copy link

xuhui-lu commented Mar 1, 2024

Hi @Rossil2012 , I resolved all comments and pushed some commits directly in this PR. Please help to verify if on your local setup. Let's merge it and cherry-pick to release 1.7 if it works.

Wow, thank you! However, in order to support per-user oauth configuration, @xuhui-lu and I determined to add a new syntax like create user u with oauth (jwks_url = 'xxx', user_id = 'xxx'). This way we can enable a more flexible check on the claims decoded from jwt, and community users can build their own oauth authentication workflow by specifying static config in user creation and dynamically check them in jwt header. I will release the details in the introduction later. The system params will not be used then🤣.

So IIUC the current implementation is not considered as a stable or final one, right? Is that so urgent that this should be released in 1.7? I would suggest to wait for 1.8 which IIRC will be frozen in recent days.

This is related to a page revamp recently proposed by yingjun. We need this feature to remove the password for accessing cloud web console.

@Rossil2012 Rossil2012 requested a review from stdrc March 1, 2024 12:16
@Rossil2012 Rossil2012 removed the user-facing-changes Contains changes that are visible to users label Mar 5, 2024
Copy link
Member

@stdrc stdrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve on behalf of Cargo-lock

@Rossil2012 Rossil2012 added this pull request to the merge queue Mar 5, 2024
Merged via the queue into main with commit 9966b81 Mar 5, 2024
28 of 30 checks passed
@Rossil2012 Rossil2012 deleted the kanzhen/rw-oauth branch March 5, 2024 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants